package com.ruoyi.web.controller.workflow;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.workflow.domain.CarPackageAudit;
import com.ruoyi.workflow.service.ICarPackageAuditService;
import com.ruoyi.workflow.service.IDoTaskService;
import org.apache.commons.compress.utils.IOUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.rmi.ServerException;
import java.util.List;

/**
 * 套餐审核Controller
 *
 * @author lhl
 * @date 2022-11-18
 */
@RestController
@RequestMapping("/workflow/task")
public class DoTaskController extends BaseController
{
    @Autowired
    private IDoTaskService doTaskService;


    /**
     * 查询套餐审核列表
     */
    @PreAuthorize("@ss.hasPermi('workflow:task:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarPackageAudit carPackageAudit)
    {
        return doTaskService.selectCarPackageAuditList(carPackageAudit);
    }
    /**
     * 审批
     */
    @PreAuthorize("@ss.hasPermi('workflow:task:todo')")
    @PostMapping("/todo")
    public AjaxResult tidoAudit(Long id,String taskId,boolean result,String info) throws ServerException {
        if (!StringUtils.hasText(info)){
            throw new ServiceException("请输入审批理由");
        }
        doTaskService.todoAudit(id,taskId,result,info);
        return AjaxResult.success("审批成功");
    }
    /**
     * 审批
     */
    @PreAuthorize("@ss.hasPermi('workflow:task:todo')")
    @PostMapping("/reapply")
    public AjaxResult reapply(Long id,String taskId) throws ServerException {
       doTaskService.reapply(id,taskId);
        return AjaxResult.success("成功");
    }
}
